<?php


namespace App\Http\Controllers\api;

use App\Services\Curl;
use App\Services\DataVerify;
use App\Services\Oss;
use Dcat\Admin\Traits\HasUploadedFile;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;


class OssController
{
    use HasUploadedFile;
    public function aliYunOss(Request $request){
        if ($this->isDeleteRequest()) {
            // 删除文件并响应
            die('删除');
        }
        $pathName = $this->file('image')->getPathname();
        //图片审核
        $imageVerify = (new DataVerify())->imageAudit($pathName);
        if($imageVerify['conclusion']=='合规'){
            $path = (new Oss())->aliyun($pathName);
            return $this->responseUploaded($path,$path);
        }
        return $this->responseErrorMessage($imageVerify['data'][0]['msg']);

    }

    public function usersOss(Request $request){
        $pathName = $this->file('avatar')->getPathname();
        $path = (new Oss())->aliyun($pathName);
        return $this->responseUploaded($path,$path);
    }
}
